<#assign tit>K-Yoga团操预约</#assign>
<@page.html title=tit>
<script type="text/javascript" src="${_appPath!}/js/cal.js"></script>
<script type="text/javascript">
  function chgmtp(t) {
    document.getElementById("th_cdno").style.display = t==1?"":"none";
    document.getElementById("td_cdno").style.display = t==1?"":"none";
    var fm = getEl("fm_input");
    fm.custName.readOnly = t==1?true:false;
    fm.custName.className = t==1?"disable":"";
    fm.mobile.readOnly = t==1?true:false;
    fm.mobile.className = t==1?"disable":"";
  }

  function getminfo(c) {
    if(c!="") {
      getJson("getMember?cardCode="+c, function(data){
        if(data.ret) {
          var mb = data.data;
          setc(mb);
        } else {
          window.alert(data.msg);
        }
      });
    }
  }
  function setc(mb) {
    var fm = getEl("fm_input");
    fm.cardCode.value = mb.card;
    fm.custName.value = mb.name;
    fm.mobile.value = mb.mobile;
    fm.leftAmount.value = mb.factAmount?(formatMoney(mb.factAmount)+"+"+formatMoney(mb.presentAmount)):"";
    fm.contractTime.value = mb.contractEnd;
  }

  var _isav = false;
  function save() {
    if(_isav) return false;
    var fm = getEl("fm_input");
    postForm(fm.action, fm, saveRet);
    return false;
  }
  function saveRet(data) {
    window.alert(data.msg);
    if(data.ret) {
      if(window.parent && window.parent.addOk)
        window.parent.addOk();
      //cancel();
      window.location = "view?id=${table.classId!}";
    } else {
      _isav = false;
    }
  }

  function cancel() {
    if(window.parent && window.parent.closeWin)
      window.parent.closeWin();
    else
      window.close();
  }
</script>
  <form id="fm_input" method="post" action="_add" onsubmit="return save(this);">
    <input type="hidden" name="classId" value="${table.classId!}">
    <table class="input w4">
      <tr>
        <th style="height:35px;">课程</th>
        <td colspan="3"><@value type="ptItemName" key="${table.ptCode!}"/></td>
      </tr>
      <tr>
        <th style="height:35px;">上课时间</th>
        <td colspan="3">${table.classTime?string('yyyy-MM-dd HH:mm')}</td>
      </tr>
      <tr>
        <th style="height:35px;">教室</th>
        <td colspan="3"><@value type="gcRoom" key="${table.shopCode!}_${table.roomCode!}"/></td>
      </tr>
      <tr>
        <th style="height:35px;">教练</th>
        <td colspan="3"><@value type="ptCoachName" key="${table.coachCode!}"/></td>
      </tr>
      <tr>
        <th>K-Yoga卡号</th>
        <td colspan="3"><input type="text" name="cardCode" value="" req="K-Yoga卡号" onchange="getminfo(this.value);" maxlength="20"></td>
      </tr>
      <tr>
        <th width="85">会员姓名</th>
        <td width="160"><input type="text" name="custName" value="" req="会员姓名" class="disable" readonly></td>
        <th width="85">手机号码</th>
        <td width="160"><input type="text" name="mobile" value="" req="手机号码" vtp="mobile" class="disable" readonly></td>
      </tr>
      <tr>
        <th>剩余金额</th>
        <td><input type="text" name="leftAmount" value="" class="disable" readonly></td>
        <th>有效期</th>
        <td><input type="text" name="contractTime" value="" maxlength="10" class="disable" readonly></td>
      </tr>
    </table>

    <div class="button"><input type="button" value="确认并提交" onclick="save();"></div>
  </form>
</@page.html>